﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ORS.BLL;

namespace ORS.Web
{
    public partial class UserQueryPaper : System.Web.UI.Page
    {

       string s_key;
       DataTable dtsheet;
       UserPaperList ivk3_processopr = new UserPaperList();
       String _auther;     
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.Session["userid"] == null)
                Response.Redirect("Login.aspx");
            else
            {
                btnreview.Visible = false;
                lblNoRecorder.Visible = false;
            }
        }

        protected void btnquery_Click(object sender, EventArgs e)
        {
            _auther = System.Web.HttpContext.Current.Session["userid"].ToString();
            if (rbtnqtype.SelectedValue == "0")
               { 
                  s_key = tbx_paper_id.Text.Trim();
                  dtsheet = ivk3_processopr.GetUserPaperInfolist_by_PaperID(s_key, _auther);
               }
            else if (rbtnqtype.SelectedValue == "1")
                    {
                       s_key = tbx_title.Text.Trim();
                       dtsheet = ivk3_processopr.GetUserPaperInfolist_by_title(s_key, _auther);
                     }
                 else  
                      {
                         s_key = DropDownList1.SelectedItem.Value.Trim();
                         dtsheet = ivk3_processopr.GetUserPaperInfolist_by_interest(s_key, _auther);
                       }

            if (dtsheet.Rows.Count != 0)
               {
                  lblNoRecorder.Visible = false;
                  btnreview.Visible = true;
                  gvpaper2.DataSource = dtsheet;
                  gvpaper2.DataBind();
               }
            else 
                {
                   lblNoRecorder.Visible = true;
                   btnreview.Visible = false;
                   gvpaper2.DataSource = dtsheet;
                   gvpaper2.DataBind();
                }
          }

        protected void btnreset_Click(object sender, EventArgs e)
        {
            tbx_paper_id.Text = "";
            tbx_title.Text = "";
        }

        protected void btnreview_Click(object sender, EventArgs e)
        {
            string[] paper_links = this.Request["paper_select"].Split(',');
            string link_url = paper_links[0].Trim();
            Response.Redirect(link_url);
        }

    }
}